package com.dp.hystrix;

import com.netflix.hystrix.HystrixCommand;
import com.netflix.hystrix.HystrixCommandGroupKey;

/**
 * TODO 类的描述
 *
 * @author 邓平
 * @createTime 2018-01-05 10:51:36
 */
public class HelloHystrixCommand extends HystrixCommand<String> {

    private String somebody;

    public HelloHystrixCommand(String somebody) {
        super(Setter.withGroupKey(HystrixCommandGroupKey.Factory.asKey("hello")));
        this.somebody = somebody;
    }

    @Override
    protected String run() throws Exception {
        //生产环境中此处为第三方依赖的具体调用逻辑
        return new StringBuilder().append("Hello ").append(somebody).toString();
    }

    @Override
    protected String getFallback() {
        return "==============Hello World, Failure";
    }
}
